package com.jt.controller;

import com.jt.pojo.ItemCat;
import com.jt.service.ItemCatService;
import com.jt.vo.SySResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/itemCat")
public class ItemCatController {
    @Autowired
    private ItemCatService service;
    @GetMapping("/findItemCatList/{level}")
    public SySResult findItemCatList(@PathVariable Integer level){

        List<ItemCat> list = service.findItemCatList(level);
        return SySResult.success(list);
    }
    @PostMapping("/saveItemCat")
    public SySResult saveItemCat(@RequestBody ItemCat itemCat){
        service.saveItemCat(itemCat);
        return SySResult.success();
    }
    @DeleteMapping("/deleteItemCat")
    public SySResult deleteItemCat(ItemCat itemCat){
        service.deleteItemCat(itemCat);
        return SySResult.success();
    }
    @PutMapping("/status/{id}/{status}")
    public SySResult status(ItemCat itemCat){
        service.status(itemCat);
        return SySResult.success();
    }
    @PutMapping("/updateItemCat")
    public SySResult updateItemCat(@RequestBody ItemCat itemCat){
        service.updateItemCat(itemCat);
        return SySResult.success();
    }
}
